package com.woniu.mapper;

import com.woniu.dto.OrderExportDTO;
import com.woniu.dto.OrderSearchDTO;
import com.woniu.entity.Order;
import com.woniu.vo.OrderVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * @author user
 * @description 针对表【order(订单主表)】的数据库操作Mapper
 * @createDate 2025-09-02 11:21:11
 * @Entity com.woniu.entity.Order
 */
public interface OrderMapper {
    // 用于导出的分页查询
    List<OrderExportDTO> findExportOrders(@Param("offset") int offset, @Param("pageSize") int pageSize);

    // 统计总数
    Integer countTotalOrders();

    // 搜索订单
    List<Order> findSearchOrders(OrderSearchDTO orderSearchDTO);

    // 逻辑删除订单
    Integer findDeleteById(String orderId);

    List<Order> findAll();

    Integer delete(String orderId);

    Integer add(Order record);

    OrderVo findById(String orderId);

    Integer update(Order record);

    // OrderMapper.java
    List<OrderVo> findPaidUnshippedOrders();


    Order getById(String orderId);

    // 更新订单状态
    int updateOrderStatus(@Param("orderId") String orderId, @Param("status") Integer status);

    // 新增：查询订单基础信息 + 收货信息
    Map<String, Object> findBaseWithAddressById(@Param("orderId") String orderId);

    int countByDate(LocalDate yesterday);

    BigDecimal sumAmountByDate(LocalDate yesterday);

    BigDecimal sumRefundByDate(LocalDate yesterday);

    int countNewUserOrders(LocalDate yesterday);

    List<Order> findReturnSearchOrders(OrderSearchDTO orderSearchDTO);
}